<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('文件列表')" />
</head>
<body class="gray-bg">
    <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="menu-form">
					<div class="select-list">
						<ul>
							<li>
								仓库名称：<select name="repositoryId" th:with="repos=${@ktRepoService.listAllEnableRepo()}" id="repositoryId">
<!--								<option value="">所有</option>-->
								<option th:each="repo : ${repos}" th:text="${repo.repositoryName}" th:value="${repo.repositoryId}"></option>
							</select>
							</li>
							<li>
								文件名称：<input type="text" name="fName"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
                
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-info" id="expandAllBtn">
                    <i class="fa fa-exchange"></i> 展开/折叠
                </a>
	        </div>
       		 <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-tree-table"></table>
	        </div>
	    </div>
	</div>
	
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var addFlag = [[${@permission.hasPermi('busi:repository_file:add')}]];
		var editFlag = [[${@permission.hasPermi('busi:repository_file:edit')}]];
		var removeFlag = [[${@permission.hasPermi('busi:repository_file:remove')}]];
		var datas = [[${@dict.getType('sys_show_hide')}]];
		var fileType = [[${@dict.getType('file_type')}]];
		var prefix = ctx + "busi/repository_file";
		var delFlag = [[${@dict.getType('del_flag')}]];
		var repositoryId = [[${repo.repositoryId}]];

		$(function() {
		    var options = {
		        code: "id",
		        parentCode: "parentId",
		        uniqueId: "menuId",
		        expandAll: false,
		        expandFirst: false,
				url: prefix + "/list/"+repositoryId,
		        createUrl: prefix + "/add/{repositoryId}/{parentId}",
		        updateUrl: prefix + "/edit/{id}",
		        removeUrl: prefix + "/remove/{id}",
		        modalName: "kettle仓库",
		        columns: [{
                    field: 'selectItem', 
                    radio: true,
					width: '20',
                 },
                 {
		            title: '文件名称',
		            field: 'fName',
		            widthUnit: '%',
					 align: "left",
		            formatter: function(value, row, index) {
						if (row.parentId == 0) {
							return '<i class="' + row.icon + '"></i> <span class="nav-label">' + row.fName + '(' + row.repositoryName + ')' + '</span>';
						} else {
							return '<i class="' + row.icon + '"></i> <span class="nav-label">' + row.fName + '</span>';
						}
					}
		        },
					{
						field: 'repositoryName',
						title: '仓库名称',
						align: "left"
					},
		        {
		            field: 'size',
		            title: '文件大小',
					align: "left",
					formatter: function (value, row, index) {
		            	var content = '-';
						if (row.type === '1') {
							if (value < 104857) { // 0.1M
								content = (value / 1024).toString().match(/^\d+(?:\.\d{0,2})?/) + 'KB'
							} else {
								content = (value / 1024 / 1024).toString().match(/^\d+(?:\.\d{0,2})?/) + 'MB'
							}
						}
						return content;
					}
		        },
					{
						field: 'type',
						title: '文件类型',
						align: "left",
						formatter: function (value, row, index) {
							return $.table.selectDictLabel(fileType, value);
						}
					},
		        {
		            title: '文件类型',
		            field: 'fType',
					align: "left"
		        }]
		    };
		    $.treeTable.init(options);
		});
	</script>
</body>
</html>